package util;

import java.io.*;
import java.util.*;

public class FileSaver {

	public static String save(String fileName, InputStream is) throws Exception {
//		String newFileName = fileName + new Date().getTime();
		String newFileName = fileName.substring(0, fileName.lastIndexOf(".")) + new Date().getTime()
											+ fileName.substring(fileName.lastIndexOf("."));
		FileOutputStream fos = new FileOutputStream(newFileName);		
		
		int readByte = -1;
		byte[] datas = new byte[1024];
		
		while( (readByte = is.read(datas, 0, 1024)) != -1 ) {
			fos.write(datas, 0, readByte);
		}		
		fos.close();
		
		return newFileName;
	}
	
}
